﻿<?php
include "../GLOBAL.php";

$i = $_POST['time'];
if($i > 10) { echo 1;exit;}
$photo = '';
$photo_min = '';
if($_FILES['photo']) {
        if($_FILES['photo']['name']=="") { echo 2;exit;}

        if (!preg_match("/\.(gif|jpg|png|jpg|png|jpeg)$/", strtolower($_FILES['photo']['name']), $matched)) {
       echo 3;exit;
    }
        $filename = strtoupper(randString(4)).date("mdHis");
        $dir = "./uploads/temp/";
        if(!checkDir($dir)) { echo 4;exit;}
        
        $r2 = uploadImage("photo",$filename,$dir,1024*1024);

        if(!$r2){
                echo 4;exit;
        }elseif($r2==-1){
                echo 3;exit;
        }elseif($r2==-2){
                echo 5;exit;
        }else{
//                if(photoThumbnail($dir.$filename.$matched[0],$dir.$filename.'-min.jpg',110,134)) 
//                {
//                        $photo_min = $filename.'-min.jpg';
//                }else{
//                        $photo_min = $filename.$matched[0];
//                        echo 4;exit;
//                }
                $photo = $filename.$matched[0];
        }
}
echo $photo;

?>